package 笔试.度小满1;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/10/23-15:39
 * @version:1.0
 * @function: 3 4
 * 08:00-09:00
 * 09:30-11:00
 * 13:00-15:00
 * 07:00-08:00
 * 08:00-11:00
 * 12:00-13:30
 * 14:00-17:00
 */
public class Main {
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] num = scanner.nextLine().split(" ");
        int l1 = Integer.parseInt(num[0]), l2 = Integer.parseInt(num[1]);
        String[] video1 = new String[l1];
        String[] video2 = new String[l2];
        for (int i = 0; i < l1; i++) {
            video1[i] = scanner.nextLine();
        }
        for (int i = 0; i < l2; i++) {
            video2[i] = scanner.nextLine();
        }
        System.out.println(l2 + 1);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String line1 = scanner.nextLine();
        int le = line1.length();
        HashMap<Character, Integer> hashMap = new HashMap<>();
        for (int i = 0; i < le; i++) {
            char c = line1.charAt(i);
            hashMap.put(c, hashMap.getOrDefault(c, 0) + 1);
        }
        int count = 0;
        int w = line.length();
        boolean flag = true;
        while (flag) {
            for (int i = 0; i < w; i++) {
                char cc = line.charAt(i);
                int n = hashMap.getOrDefault(cc, 0);
                if (n == 0) {
                    flag = false;
                    count--;
                    for (int j = 0; j < i; j++) {
                        char ch = line.charAt(j);
                        hashMap.put(ch, hashMap.getOrDefault(ch, 0) + 1);
                    }
                    break;
                } else {
                    hashMap.put(cc, n - 1);
                }
            }
            count++;
        }
        int res = 0;
        for (Character character : hashMap.keySet()) {
            if (hashMap.getOrDefault(character, 0) > 0) {
                res++;
            }
        }
        System.out.println(count + " " + res);
    }
}
